FROM centos:centos7.5.1804
LABEL maintainer="mario"
ADD src/ /usr/local/src
RUN echo Asia/Shanghai >/etc/timezone \
    && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
	&& curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo \
	&& yum install -y epel-release \
    && yum install -y gcc gcc-c++ gdbm-devel readline-devel ncurses-devel \
       zlib-devel bzip2-devel sqlite-devel db4-devel openssl-devel tk-devel \
       bluez-libs-devel make cmake  mysql-devel openldap-devel git \
       libselinux-python sshpass unzip openldap-devel nginx python-devel python2-wheel \
	&& useradd ansible \
    && echo 'ansible ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers \
    && echo 'source /usr/local/envansible/bin/activate' >> /home/ansible/.bashrc \
    && echo 'export PATH=$PATH:/usr/local/envansible/bin' >> /home/ansible/.bashrc \
    && tar -zxvf  /usr/local/src/Python-2.7.tgz -C /usr/local/src \
    && cd /usr/local/src/Python-2.7 && ./configure && make && make install \
    && mv /usr/bin/python /usr/bin/python.bak \
    && ln -sf /usr/local/bin/python2.7 /usr/bin/python \
	&& sed -i -e '1 s#\(/usr/bin/python\).*#\12.7#g' /usr/bin/yum \
    && sed -i -e '1 s#\(/usr/bin/python\).*#\12.7#g' /usr/libexec/urlgrabber-ext-down \
    && bash /usr/local/src/setuptools-0.6c11-py2.7.egg \
    && tar zxvf /usr/local/src/pip-20.0.tar.gz -C /usr/local/src \
    && cd /usr/local/src/pip-20.0 && python setup.py install \
    && mkdir ~/.pip && mv /usr/local/src/pip.conf ~/.pip/ \
    && pip install virtualenv \
    && virtualenv /usr/local/envansible \
    && . /usr/local/envansible/bin/activate	\
    && mv /usr/local/src/ansible_ui /usr/local/ \
    && pip install -r /usr/local/ansible_ui/requirements.txt --no-index --find-links=/usr/local/src/pip-module \
    && mv /usr/local/src/copy.sh /usr/local/bin/ \
    && chmod +x /usr/local/bin/copy.sh \
    && sed -i -e '36 aos.popen("/usr/local/bin/copy.sh")' /usr/local/envansible/lib/python2.7/site-packages/ansible/runner/action_plugins/copy.py \
    && chown -R ansible.ansible /usr/local/ansible_ui \
    && setfacl -R -m u:ansible:rwx /usr/local/ansible_ui \
    && setfacl -R -m d:u:ansible:rwx /usr/local/ansible_ui \
    && chmod -R 755 /usr/local/ansible_ui \
    && chmod -R 777 /tmp && chmod 700 /usr/local/ansible_ui/celery-conf/supervisord.conf \
    && cp /usr/local/ansible_ui/ansible-conf/ansible.cfg /home/ansible/.ansible.cfg \
    && mv /usr/local/src/virtual.conf /etc/nginx/conf.d/ \
    && mv /usr/local/src/nginx.conf /etc/nginx/	\
    && mv /usr/local/src/entrypoint.sh /bin/ && chmod +x /bin/entrypoint.sh \
    && rm -rf /usr/share/nginx/html/index.html /var/cache/yum/* /usr/local/src/*	
	
ENV LANG en_US.utf8
ENV LC_ALL en_US.utf8
ENTRYPOINT ["/bin/entrypoint.sh"]
